set (dicom_SRC
    # ../contrib/mongoose/mongoose.c
    dmv_db.cpp
    file_object.cpp
    hippa_log.cpp
    handler/handler_common.cpp

    handler/login_handler.cpp
    handler/file_upload_handler.cpp
    handler/lookup_handler.cpp
    handler/readdir_handler.cpp
    handler/file_op_handler.cpp
    handler/dir_op_handler.cpp
    handler/file_download_handler.cpp
    handler/statfs_handler.cpp

    upload/hash_cache.cpp
    upload/same_hash_checker.cpp
    upload/cloud_uploader.cpp
    upload/resume_info.cpp
    upload/cloud_login.cpp

    dicom_conf.cpp
    ref_object.cpp
    sync_manager.cpp
    restful_url.cpp
    session.cpp
    storage/local_cache.cpp
    web_server.cpp
    gateway.cpp
    put_handler.cpp
    storage/stream.cpp
    storage/encrypt.cpp
    storage/encrypt_stream.cpp
    storage/decrypt.cpp
    recovery/recovery.cpp
    )

add_library(dicom_core STATIC ${dicom_SRC})

target_link_libraries(dicom_core gwbase surbasic borzoi onion_static 
    curl pthread ssl jsoncpp_static pcre sqlite3 crypto z)

add_executable(dicom main.cpp)
target_link_libraries(dicom dicom_core gwbase surbasic borzoi onion_static 
    curl pthread ssl jsoncpp_static pcre sqlite3 crypto z)

add_executable(dicom_recovery recovery/recovery_cmd.cpp)
target_link_libraries(dicom_recovery dicom_core gwbase surbasic borzoi onion_static 
    curl pthread ssl jsoncpp_static pcre sqlite3 crypto z)

add_executable(restful_url_test restful_url_test.cpp)
target_link_libraries(restful_url_test dicom_core
    pthread ssl jsoncpp_static pcre sqlite3 crypto z)

add_executable(session_test session_test.cpp)
target_link_libraries(session_test dicom_core gwbase surbasic borzoi onion_static 
    curl pthread ssl jsoncpp_static pcre sqlite3 crypto z)
 
install(TARGETS dicom DESTINATION bin)
install(TARGETS dicom_recovery DESTINATION bin)
install(FILES ../dicom.conf.sample DESTINATION share/dicom/)

# for tests
add_subdirectory(upload)
add_subdirectory(storage)
